<?php

class ModelProvider extends CComponent {
	
	public $modelName;
	public $criteria = array();
	
	public function getModel($id=null) {
		$rawModel = $this->getRawModel();
		return $id ? $rawModel->findByPk($id) : $rawModel;
	}
	
	protected function getRawModel() {
		$model = new $this->modelName;
		$criteria = $model->getDbCriteria();
		$criteria->mergeWith($this->criteria);
		return $model;
	}
	
}

?>